package cn.kgc.springbootdemo.util;

import cn.kgc.springbootdemo.enums.BucketEnum;
import lombok.experimental.UtilityClass;

import java.util.Objects;

/**
 * <h3>springbootdemo</h3>
 * <p>bucket工具类</p>
 *
 * @author : DongZeJian
 * @date : 2020-12-22 17:20
 **/
@UtilityClass
public class BucketUtils {

    /**
     * 根据bucketCode获取bucket名称
     *
     * @param bucketCode : bucketCode定义值
     * @return 返回对应bucketCode对应的bucket名称
     */
    public String getValue(Integer bucketCode) {
        if (Objects.isNull(bucketCode)) {
            return null;
        }
        for (BucketEnum bucketEnum : BucketEnum.values()) {
            if (bucketEnum.getBucketCode().equals(bucketCode)) {
                return bucketEnum.getBucketName();
            }
        }
        return null;
    }
}
